package com.heima.article.controller.v1;

import cn.hutool.core.convert.Convert;
import com.heima.article.service.ArticleService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.article.pojos.ApArticle;
import org.springframework.web.bind.annotation.*;
import static com.heima.common.constants.ArticleConstants.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {
    @Resource
    private ArticleService articleService;
    @PostMapping("/load")
    public ResponseResult<List<ApArticle>> load(@RequestBody ArticleHomeDto dto) {
        List<ApArticle> load = articleService.load(LOADTYPE_LOAD_MORE, dto);
        return ResponseResult.okResult(load);
    }

    @PostMapping("/loadmore")
    public ResponseResult<List<ApArticle>> loadMore(@RequestBody ArticleHomeDto dto) {
        List<ApArticle> load = articleService.load(LOADTYPE_LOAD_MORE, dto);
        return ResponseResult.okResult(load);
    }

    @PostMapping("/loadnew")
    public ResponseResult<List<ApArticle>> loadNew(@RequestBody ArticleHomeDto dto) {
        List<ApArticle> load = articleService.load(LOADTYPE_LOAD_NEW, dto);
        return ResponseResult.okResult(load);
    }
}
